package com.algorithm.classics150.链表;

public class 环形链表_141 {
    public boolean hasCycle(ListNode head) {
        if (head == null || head.next == null || head.next.next == null){
            return false;
        }
        ListNode first = head.next.next;
        ListNode second = head.next;

        while (first != second){
            if (first.next == null || first.next.next == null){
                return false;
            }
            first = first.next.next;
            second = second.next;
        }
        return true;
    }
}
